package ar.com.ford.it.fullEconomics.facade;

import java.sql.Timestamp;
import java.util.Collection;
import ar.com.ford.it.fullEconomics.exception.FullEconomicsException;
import ar.com.ford.it.fullEconomics.logic.PricingLogic;
import ar.com.ford.it.fullEconomics.persistence.dto.Teesg01Plant;
import ar.com.ford.it.fullEconomics.persistence.dto.Teesp01Part;
import ar.com.ford.it.fullEconomics.persistence.dto.Teesp04Supply;
import ar.com.ford.it.fullEconomics.persistence.dto.Teesp05Pricing;
import ar.com.ford.it.fullEconomics.struct.PricingStruct;
import ar.com.ford.it.fullEconomics.wslx.FullEconomicsWslxUser;

public class PricingFacade {
    /**
     * Busca pricing segun supply y fecha efectiva relacionada
     * 
     * @param pricing
     * @return
     * @throws FullEconomicsException
     */
    public Collection<PricingStruct> findPricing(Teesp05Pricing pricing,
                                                 Timestamp fechaInS,
                                                 Timestamp fechaInE,
                                                 Timestamp fechaOutS,
                                                 Timestamp fechaOutE)
            throws FullEconomicsException {
        PricingLogic logic = new PricingLogic();
        Collection<PricingStruct> ret = logic.findPricing(pricing, fechaInS,
                fechaInE, fechaOutS, fechaOutE);

        return ret;
    }

    public boolean findPricingExisting(Teesp05Pricing pricing,
                                       Timestamp fechaInS, Timestamp fechaInE)
            throws FullEconomicsException {
        PricingLogic logic = new PricingLogic();
        Boolean ret = null;
        return ret = logic.findPricingExisting(pricing, fechaInS, fechaInE);
    }

    /**
     * Crea una precio a un supply seleccionado
     * 
     * @param pricing
     * @param user
     * @throws FullEconomicsException
     */
    public void createPricing(Teesp05Pricing pricing, FullEconomicsWslxUser user)
            throws FullEconomicsException {
        PricingLogic logic = new PricingLogic();
        logic.createPricing(pricing, user);
    }

    /**
     * Elimina un pricing
     * 
     * @param pricing
     * @param user
     * @throws FullEconomicsException
     */
    public void deletedPricing(Teesp05Pricing pricing,
                               FullEconomicsWslxUser user)
            throws FullEconomicsException {
        PricingLogic logic = new PricingLogic();
        logic.deletedPricing(pricing);
    }

    /**
     * Actualiza Pricing
     * 
     * @param pricing
     * @param user
     * @throws FullEconomicsException
     */
    public void updatePricing(Teesp05Pricing pricing, FullEconomicsWslxUser user)
            throws FullEconomicsException {
        PricingLogic logic = new PricingLogic();
        logic.updatePricing(pricing, user);
    }

    /**
     * Busqueda general por supply y fecha efectiva
     * 
     * @param pricing
     * @return
     * @throws FullEconomicsException
     */
    public Collection<Teesp05Pricing> findAllPricing(Teesp05Pricing pricing)
            throws FullEconomicsException {
        PricingLogic logic = new PricingLogic();
        return logic.findAllPricing(pricing);
    }

    /**
     * Busca una parte segun su pk.
     * 
     * @param plant
     * @param classCode
     * @param prefijo
     * @param base
     * @param sufijo
     * @return
     * @throws FullEconomicsException
     */
    public Teesp01Part findPart(Teesg01Plant plant, String classCode,
                                String prefijo, String base, String sufijo)
            throws FullEconomicsException {
        PricingLogic logic = new PricingLogic();
        return logic.findPart(plant, classCode, prefijo, base, sufijo);
    }

    /**
     * Verifica que el supply que se queire asociar el precio exista
     * 
     * @param pricing
     * @return
     * @throws FullEconomicsException
     */
    public boolean verificSupply(Teesp05Pricing pricing)
            throws FullEconomicsException {
        PricingLogic logic = new PricingLogic();
        return logic.verificSupply(pricing);
    }

    /**
     * Busca un pricing en determinada fecha
     * 
     * @param pricing
     * @return
     * @throws FullEconomicsException
     */
    public Teesp05Pricing findPricingByDate(Teesp04Supply supply, Timestamp date)
            throws FullEconomicsException {
        Teesp05Pricing ret = null;
        PricingLogic logic = new PricingLogic();
        ret = logic.findPricingByDate(supply, date);
        return ret;
    }
}
